package com.training.java.core.collections.one;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class MapLaptopDemo {

	public static void main(String[] args) {

		Map<String, String> laptop = new HashMap<>();
		laptop.put("Venkat","MacBook");
		laptop.put("Shawn","Dell");
		laptop.put("Reenu","HP");
		
		//Read Venkat's laptop
		
		String VenkatsLaptop = laptop.get("Venkat");
		System.out.println("Venkat's laptop = " + VenkatsLaptop );
		System.out.println("*************************");
		// second approach gets all keys first and ask for value
		
		Set<String> keys = laptop.keySet();
		
		for (String eachLaptop : keys)
		{
			String value = laptop.get(eachLaptop);
			System.out.println("Key = " + eachLaptop + " and value = " + value);
		}
			
			System.out.println("*************************");
		// third approach gets all entries and ask that entry for key and value
		
		Set<Entry<String, String>> entries = laptop.entrySet();
		
		for(Entry<String, String> entry : entries)
		{
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("Key = " + key + " and value = " + value);
		}

}
}